﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;
using viBook.Models;

namespace viBook.Controllers
{
    public class AuthorsController : BaseController
    {
        #region Constructors and Repository vars

        private readonly IAuthorRepository _authorRepository;

        public AuthorsController()
            : this(new AuthorRepository())
        {
        }

        public AuthorsController(IAuthorRepository authorRepository)
        {
            _authorRepository = authorRepository;
        }

        #endregion


        //todo: Search author
        public string Search(string q, int limit)
        {
            var result = _authorRepository.FindAuthors(q, limit);
            return String.Join(Environment.NewLine, result);
        }
    }
}